package com.iocup.keybastion.core.client;



import com.iocup.keybastion.context.WebContextHolder;
import com.iocup.keybastion.core.credentials.Credentials;
import com.iocup.keybastion.core.profile.UserProfile;
import com.pine.sunflower.core.Typer;

import java.util.Optional;

/**
 * @Description: 认证信息获取客户端，获取凭证和用户信息
 * @Author: xyjxust
 * @Date: 2022/3/2 9:18
 */
public interface Client<T extends Credentials> extends Typer {


    /**
     * 刷新用户配置信息
     *
     * @param contextHolder
     * @return
     */
    Optional<UserProfile> refreshUserDetail(WebContextHolder contextHolder);



    /**
     * 获取凭证
     *
     * @param webContextHolder
     * @return
     */
    Optional<T> getCredentials(WebContextHolder webContextHolder);

    /**
     * 通过凭证获取用户信息
     *
     * @param credentials
     * @param contextHolder
     * @return
     */
    Optional<UserProfile> getUserDetail(T credentials, WebContextHolder contextHolder);

    /**
     * 登出处理
     * @param webContextHolder
     * @param loginName
     * @param device
     * @param targetUrl
     * @return
     */
    void doLogoutAction(WebContextHolder webContextHolder,
                        String loginName,
                        String device,
                        String targetUrl);

}
